package flink.function;

import org.apache.flink.api.common.functions.MapFunction;

import com.alibaba.fastjson.JSONObject;

/**
 * @author ：Jason
 * @date ：Created in 2023/4/30 1:14 PM
 * @description：把 JSONObject 类型转成 POJO 类型
 * @modified By：
 * @version: 1.0
 */
public class MapAddKeyValueFunction implements MapFunction<JSONObject, JSONObject> {
    private final String key;
    private final String value;

    public MapAddKeyValueFunction(String key, String value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public JSONObject map(JSONObject jsonObject) throws Exception {
        jsonObject.put(key, value);
        return jsonObject;
    }
}
